<script src="<{$config.weburl}>/script/jquery-1.4.4.min.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8" src="<{$config.weburl}>/script/district.js" ></script>
<script type="text/javascript" src="<{$config.weburl}>/script/jquery.validation.min.js"></script>
<script language="javascript">
var weburl="<{$config.weburl}>";
$(function(){
	$('#form').validate({
		errorPlacement: function(error, element){
			element.nextAll('.form-error').append(error);
		},      
		rules : {
			name:{
				required:true,
			},
			address:{
				required:true,
			},
			mobile:{
				required:true,
				digits:true,
			},
			<{if !$de.area}>
			select_1:{
				required:true,
			},
			select_2:{
				required:true,
			},
			select_3:{
				required:true,
			},
			<{/if}>
		},
		messages : {
			name:{
				required:'请填写收货人',
			},
			address:{
				required:'请填写街道地址',
			},
			mobile:{
				required:'请填写手机号',
				digits:'请填写正确手机号',
			},
			<{if !$de.area}>
			select_1:{
				required:'请选择省份',
			},
			select_2:{
				required:'请选择城市',
			},
			select_3:{
				required:'请选择区县',
			},
			<{/if}>
		}
	});
});
</script>
<header>
	<div class="nav-w">
    	<section class="nav-s"><a href="<{$config.weburl}>/main.php"><nav>我的商城</nav></a></section>
    	<section class="nav-c"><span>收货地址</span></section>
    	<section class="nav-e"></section>
    </div>
</header>
<link href="<{$config.weburl}>/templates/wap/css/orderadder.css" rel="stylesheet" type="text/css" />
<section class="orderadder">
<{if $smarty.get.type=='add' or $smarty.get.type=='edit'}>
    <form id="form" name="form" action="" method="post">
    <input type="hidden" value="<{$de.id}>" name="edid">
    <input type="hidden" value="<{$smarty.get.t}>" name="ty">
    <input type="hidden" value="<{$smarty.get.i}>" name="i">
    <input type="hidden" value="<{if $de.id}>edit<{else}>add<{/if}>" name="submit">
    <dl>
        <dt>收货人姓名：</dt>
        <dd><input type="text" maxlength="30" name="name" value="<{$de.name}>"> <div id="form-error" class="form-error"></div></dd>
    </dl>
     <dl>
        <dt>手机号码：</dt>
        <dd><input type="text" name="mobile" id="mobile" maxlength="18" value="<{$de.mobile}>"><div id="form-error" class="form-error"></div></dd>
    </dl>
    
    <dl>
        <dt>所在区域：
        <input type="hidden" name="t" id="t" value="<{$de.area}>" />
        <input type="hidden" name="province" id="id_1" value="<{$de.provinceid}>" />
        <input type="hidden" name="city" id="id_2" value="<{$de.cityid}>" />
        <input type="hidden" name="area" id="id_3" value="<{$de.areaid}>" />
        </dt>
        <{if $de.area}>
        <dd id="d_1"><{$de.area}>&nbsp;&nbsp;<a href="javascript:sd();">编辑</a></dd><{/if}>
        <dd id="d_2" class="<{if $de.area}>hidden<{/if}>">
            <select id="select_1" name="select_1" onChange="district(this);">
            	<option value="">--请选择--</option>
            	<{$prov}>
            </select>
            <select id="select_2" name="select_2" onChange="district(this);" class="hidden"></select>
        
        	<select id="select_3" name="select_3" onChange="district(this);" class="hidden"></select>
            <div id="form-error" class="form-error"></div>
        </dd>
    </dl>
    <dl>
        <dt>街道地址：</dt>
        <dd>
            <input type="text" value="<{$de.address}>" name="address" id="address"><div id="form-error" class="form-error"></div>
        </dd>
    </dl>
    <dl>
        <dt>设为默认：</dt>
        <dd>&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="default" value="1" <{if $de.default!=1 }>checked="checked"<{/if}> /></dd>
    </dl>
   	<input type="submit" value="保存地址" class="submit">
    </form>
<{else}>
    <ul>
        <{foreach item=list key=num from=$list}>
        <li>
        	<a href="<{$config.weburl}>/main.php?m=member&s=admin_orderadder&id=<{$list.id}>&type=edit<{if $smarty.get.t}>&t=<{$smarty.get.t}><{/if}><{if $smarty.get.i}>&i=<{$smarty.get.i}><{/if}>">
            <p>
                <span><{$list.name}></span>
				<span><{$list.mobile}></span>
                <span><{if $list.default==2}>默认<{/if}></span>
            </p>
            <p><span><{$list.area}>&nbsp;<{$list.address}></span></p>
            </a>
            <a class="del" href="<{$config.weburl}>/main.php?m=member&s=admin_orderadder&edid=<{$list.id}>">删除</a>
        </li>  
        <{/foreach}>
    </ul>
    <div class="add"><a href="main.php?m=member&s=admin_orderadder&type=add&type=add<{if $smarty.get.t}>&t=<{$smarty.get.t}><{/if}><{if $smarty.get.i}>&i=<{$smarty.get.i}><{/if}>">添加新地址</a></div>
<{/if}>
</section>